﻿using System;
namespace Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RiigiOigusabi", Namespace="http://producers.etoimik.xtee.riik.ee/producer/etoimik", Target=typeof(RiigiOigusabi))]
    public class RiigiOigusabiSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRiigiOigusabi clazz;
        
        public RiigiOigusabiSerializer(IRiigiOigusabi clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.TyypKL!=null) {
                Writer.WriteStartElement("TyypKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.TyypKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.LiikKL!=null) {
                Writer.WriteStartElement("LiikKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.LiikKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Kaugus!=null) {
                Writer.WriteStartElement("Kaugus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Kaugus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KaugusYhikKL!=null) {
                Writer.WriteStartElement("KaugusYhikKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.KaugusYhikKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OsutamiseKoht!=null) {
                Writer.WriteStartElement("OsutamiseKoht");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OsutamiseKoht))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OsutamiseAlgusKP!=null) {
                Writer.WriteStartElement("OsutamiseAlgusKP");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.OsutamiseAlgusKP))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OsutamiseLoppKP!=null) {
                Writer.WriteStartElement("OsutamiseLoppKP");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.OsutamiseLoppKP))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OsutamiseAeg!=null) {
                Writer.WriteStartElement("OsutamiseAeg");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.OsutamiseAeg))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OsutamiseAegYhikKL!=null) {
                Writer.WriteStartElement("OsutamiseAegYhikKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.OsutamiseAegYhikKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Kirjeldus!=null) {
                Writer.WriteStartElement("Kirjeldus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kirjeldus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Koefitsient!=null) {
                Writer.WriteStartElement("Koefitsient");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Koefitsient))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Markused!=null) {
                Writer.WriteStartElement("Markused");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Markused))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TasuSumma!=null) {
                Writer.WriteStartElement("TasuSumma");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.TasuSumma))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TasuSummaKM!=null) {
                Writer.WriteStartElement("TasuSummaKM");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.TasuSummaKM))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TasuSummaValuutaKL!=null) {
                Writer.WriteStartElement("TasuSummaValuutaKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.TasuSummaValuutaKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MaaratudTasuSumma!=null) {
                Writer.WriteStartElement("MaaratudTasuSumma");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.MaaratudTasuSumma))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MaaratudTasuSummaKM!=null) {
                Writer.WriteStartElement("MaaratudTasuSummaKM");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.MaaratudTasuSummaKM))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MaaratudTasuSummaValuutaKL!=null) {
                Writer.WriteStartElement("MaaratudTasuSummaValuutaKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.MaaratudTasuSummaValuutaKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AlgusKP!=null) {
                Writer.WriteStartElement("AlgusKP");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.AlgusKP))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Alustaja!=null) {
                Writer.WriteStartElement("Alustaja");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Alustaja))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ObjektID!=null) {
                Writer.WriteStartElement("ObjektID");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.ObjektID))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KlientsysteemiID!=null) {
                Writer.WriteStartElement("KlientsysteemiID");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KlientsysteemiID))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="TyypKL") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.TyypKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("TyypKL")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="LiikKL") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.LiikKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("LiikKL")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Kaugus") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Kaugus = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("Kaugus")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="KaugusYhikKL") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.KaugusYhikKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("KaugusYhikKL")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="OsutamiseKoht") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.OsutamiseKoht = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("OsutamiseKoht")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="OsutamiseAlgusKP") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.OsutamiseAlgusKP = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("OsutamiseAlgusKP")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="OsutamiseLoppKP") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.OsutamiseLoppKP = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("OsutamiseLoppKP")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="OsutamiseAeg") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.OsutamiseAeg = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("OsutamiseAeg")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="OsutamiseAegYhikKL") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.OsutamiseAegYhikKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("OsutamiseAegYhikKL")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Kirjeldus") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Kirjeldus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Kirjeldus")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Koefitsient") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Koefitsient = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("Koefitsient")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Markused") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Markused = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Markused")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="TasuSumma") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.TasuSumma = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("TasuSumma")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="TasuSummaKM") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.TasuSummaKM = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("TasuSummaKM")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="TasuSummaValuutaKL") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.TasuSummaValuutaKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("TasuSummaValuutaKL")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="MaaratudTasuSumma") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MaaratudTasuSumma = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("MaaratudTasuSumma")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="MaaratudTasuSummaKM") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MaaratudTasuSummaKM = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("MaaratudTasuSummaKM")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="MaaratudTasuSummaValuutaKL") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MaaratudTasuSummaValuutaKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("MaaratudTasuSummaValuutaKL")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="AlgusKP") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AlgusKP = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("AlgusKP")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Alustaja") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Alustaja = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Alustaja")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="ObjektID") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RiigiOigusabi>ObjektID");
                }
                clazz.ObjektID = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("ObjektID")).Value;
            }
            if (Reader.LocalName=="KlientsysteemiID") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.KlientsysteemiID = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("KlientsysteemiID")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
        }
    }
}
